package com.lottery.controller.pc28.accoutController;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lottery.dto.ResultDto;
import com.lottery.dto.UtilsDto;
import com.lottery.service.pc28.accoutService.LocalauthService;
import com.lottery.service.pc28.accoutService.UserService;
import com.lottery.tool.ValidateCode;
import com.lottery.utils.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;

//用户注册,登录
public class UserController {

    @Autowired
    private UserService userservice;

    @Autowired
    private LocalauthService localauthservice;

    // 日志
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    // 用户登录produces = "application/json;charset=utf-8"
    @RequestMapping(value = "/api/user/public/login", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})
    public String Login(HttpServletRequest request) {
        JSONObject jObject = new JSONObject();
        try {
            long starttime = System.currentTimeMillis();
            String body = readHttpBody(request);
            String hostAddr = request.getRemoteAddr();
            logger.info("********Login in********:" + body);
            JSONObject obj = JSONObject.parseObject(body);

            int loginType = obj.getInteger("loginType") == null ? 0 : obj.getInteger("loginType");
            String deviceId = obj.getString("deviceId");
            if (loginType == 1) { // 游客登录
                String loaclauth = localauthservice.login("", "", deviceId, hostAddr, loginType);
                return loaclauth;
            }

            String phoneNum = obj.getString("username");
            String password = obj.getString("password");
            logger.info("phone_num:{},password:{},deviceId:{}, hostAddr:{}", phoneNum, password, deviceId, hostAddr);

            String loaclauth = localauthservice.login(phoneNum, password, deviceId, hostAddr, loginType);
            long endtime = System.currentTimeMillis();
            logger.info("********Login out[chargetime {}ms]********:{}", endtime - starttime, loaclauth);
            return loaclauth;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("*****Login error******:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");
        }
        return jObject.toJSONString();
    }

/*	// 用户注册
	
	@RequestMapping(value = "/api/user/public/createaccount", method = RequestMethod.POST, produces = {
			"application/json;charset=UTF-8" })
	
	public String register(HttpServletRequest request) {
		JSONObject jObject = new JSONObject();
		try {
			String body = readHttpBody(request);
			logger.info("********createaccount********:" + body);
			JSONObject obj = JSONObject.parseObject(body);

			String phoneNum = obj.getString("phoneNum");
			String password = obj.getString("password");
			String smscode = obj.getString("smscode");
			String agencyId = obj.getString("agencyId");
			String city = obj.getString("city");
			String recommendCode = obj.getString("recommendCode");
			logger.info("smscode deviceId:{},phone_num:{}, vercode:{}, agencyId:{}, recommendCode:{}, city{}", phoneNum,
					password, smscode, agencyId, recommendCode, city);
			String loaclauth = localauthservice.regist(phoneNum, password, smscode, agencyId, recommendCode, city);
			return loaclauth;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("*****register error******:", e);
			jObject.put("result", "1");
			jObject.put("msg", "异常");
		}
		return jObject.toJSONString();
	}*/

    /**
     * 用户注册new
     */
    @RequestMapping(value = "/api/user/public/createaccount", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})

    public ResultDto register(HttpServletRequest request) {
        ResultDto result = new ResultDto();
        JSONObject jObject = new JSONObject();
        try {
            String body = readHttpBody(request);
            logger.info("********createaccount********:" + body);
            JSONObject obj = JSONObject.parseObject(body);
            String username = obj.getString("username");
            String password = obj.getString("password");
            String confirmPs = obj.getString("confirmPassword");
            String agencyId = obj.getString("agencyId");
            if(password.equalsIgnoreCase(confirmPs)){
               String pwd = UtilsDto.crypt(password);
                logger.debug("register param ::userName:{},password:{},agencyId:{}",username,pwd,agencyId);
                localauthservice.regist(username,pwd,agencyId);
                result.setResultData(true,"用户注册成功",0,null);
            }else {
                result.setResultData(false,"两次密码输入不匹配",1,null);
            }

        } catch (Exception e) {
            logger.error("register error :: e,{}",e);
            result.setResultData(false,"用户注册失败",1,null);
        }
        return result;
    }

    /**
     * 验证账户名字的唯一性
     *
     * @param request username:账户名
     * @return
     */
    @RequestMapping(value = "/api/user/public/checkUserName", method = RequestMethod.POST)
    public ResultDto checkUserName(HttpServletRequest request) {
        JSONObject object = new JSONObject();
        ResultDto result = new ResultDto();
        String body = null;
        try {
            body = readHttpBody(request);
            logger.info("********checkUserName********:" + body);
            JSONObject obj = JSONObject.parseObject(body);
            String username = obj.getString("username");
            boolean flag = userservice.checkUsername(username);
            if (flag) {
                result.setResultData(true, "该账户可以注册", 0, null);
            } else {
                result.setResultData(false, "该用户名已使用", 1, null);
            }
        } catch (IOException e) {
            logger.error("checkUserName error :: {}", e);
            result.setResultData(false, "验证账户名失败", 1, null);
        }
        return result;
    }

    // 下载验证码调用的方法
    @RequestMapping("/api/user/download")
    public String downloadFile(HttpServletRequest request, HttpServletResponse response) {
        JSONObject jObject = new JSONObject();
        try {
            String fileName = request.getParameter("fileName") == null ? "" : request.getParameter("fileName");
            if (fileName != null) {
                // String realPath =
                // request.getServletContext().getRealPath("WEB-INF/File/");
                File file = new File("E:\\", fileName);
                if (file.exists()) {
                    response.setContentType("application/force-download");// 设置强制下载不打开
                    response.addHeader("Content-Disposition", "attachment;fileName=" + fileName);// 设置文件名
                    byte[] buffer = new byte[1024];
                    FileInputStream fis = null;
                    BufferedInputStream bis = null;
                    try {
                        fis = new FileInputStream(file);
                        bis = new BufferedInputStream(fis);
                        OutputStream os = response.getOutputStream();
                        int i = bis.read(buffer);
                        while (i != -1) {
                            os.write(buffer, 0, i);
                            i = bis.read(buffer);
                        }
                    } catch (Exception e) {
                        logger.error("*****downloadFile error******:", e);
                        e.printStackTrace();
                    } finally {
                        if (bis != null) {
                            try {
                                bis.close();
                            } catch (IOException e) {

                                e.printStackTrace();
                            }
                        }
                        if (fis != null) {
                            try {
                                fis.close();
                            } catch (IOException e) {

                                e.printStackTrace();
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            logger.error("*****downloadFile error******:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");
        }
        return jObject.toJSONString();
    }

    // 验证码
    @RequestMapping(value = "/api/user/public/verificationcode", method = RequestMethod.POST)
    public void cationcode(HttpServletRequest request, HttpServletResponse response) {
        JSONObject jObject = new JSONObject();
        try {
            // String deviceId = request.getParameter("deviceId") == null ? "" :
            // request.getParameter("deviceId");
            String body = readHttpBody(request);
            // 日志
            logger.info("********verificationcode in********:" + body);

            JSONObject obj = JSON.parseObject(body);

            String deviceId = obj.getString("deviceId");
            logger.info("verificationcode:{}", deviceId);

            // response.setContentType("image/jpeg");
            response.setContentType("blob");
            // 禁止图像缓存。
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            response.setDateHeader("Expires", 0);

            ValidateCode vCode = new ValidateCode(120, 40, 4, 100);
            localauthservice.cationcode(deviceId, vCode.getCode());
            vCode.write(response.getOutputStream());

            logger.info("********verificationcode out********:" + vCode.getCode());
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("cationcode exception:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");
        }

    }

    // 加的方法用于下面 短信发送是的调用
    private String readHttpBody(HttpServletRequest request) throws IOException {

        // 读取input流
        // BufferedReader br = new BufferedReader(
        // new InputStreamReader((ServletInputStream) request.getInputStream(),
        // "utf-8"));
        // StringBuffer sb = new StringBuffer("");
        // String temp;
        // while ((temp = br.readLine()) != null) {
        // sb.append(temp);
        // }
        // br.close();

        return (String) request.getAttribute("json");
    }

    // 获取短信验证码
    @RequestMapping(value = "/api/user/public/smscode", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})
    public String Sms(HttpServletRequest request) {
        JSONObject jObject = new JSONObject();
        try {
            String body = readHttpBody(request);
            // 日志
            logger.info("********smscode in********:" + body);
            JSONObject obj = JSON.parseObject(body);

            String deviceId = obj.getString("deviceId");
            String phoneNum = obj.getString("phoneNum");
            String vercode = obj.getString("vercode");
            int smsFlag = obj.getInteger("smsFlag") == null ? 0 : obj.getInteger("smsFlag");
            logger.info("smscode deviceId:{},phone_num:{}, vercode:{}", deviceId, phoneNum, vercode);

            String loaclauth = localauthservice.Sms(deviceId, phoneNum, vercode, smsFlag);
            logger.info("********smscode out********:" + loaclauth);
            return loaclauth;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("*****Sms error******:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");

        }
        return jObject.toJSONString();
    }

    // 用户完善信息
    @RequestMapping(value = "/api/user/perfectdata", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})
    public String updateUser(HttpServletRequest request) {
        JSONObject jObject = new JSONObject();
        try {
            String body = readHttpBody(request);
            // 日志
            logger.info("********perfectdata in********:" + body);

            JSONObject obj = JSONObject.parseObject(body);
            int userId = obj.getInteger("userId");
            String userName = obj.getString("userName");
            String headPic = obj.getString("headPic");
            String phoneNum = obj.getString("phoneNum");
            String realName = obj.getString("realName");
            String city = obj.getString("city");
            String identityCard = obj.getString("identityCard");
            String smscode = obj.getString("smscode");
            String recommendCode = obj.getString("recommendCode");
            logger.info(
                    "smscode user_id:{},user_name:{},head_pic:{},phone_num:{}, real_name:{}, identity_card:{}, smscode:{}, city{}",
                    userId, userName, headPic, phoneNum, realName, identityCard, smscode, city);
            String user = userservice.updateUser(userId, userName, headPic, phoneNum, realName, identityCard, smscode,
                    recommendCode, city);

            logger.info("********perfectdata out********:" + user);

            return user;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("*****updateUser error******:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");
        }
        return jObject.toJSONString();
    }

    // 修改密码
    @RequestMapping(value = "/api/user/updatepassword", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})
    public String updatepassword(HttpServletRequest request) {
        JSONObject jObject = new JSONObject();
        try {
            String body = readHttpBody(request);

            logger.info("********updatepassword in********:" + body);

            JSONObject obj = JSONObject.parseObject(body);
            Integer userId = obj.getInteger("userId");
            String oldpassword = obj.getString("oldpassword");
            String newpassword = obj.getString("newpassword");
            logger.info("smscode user_id:{},oldpassword:{}, newpassword:{}", userId, oldpassword, newpassword);
            String loaclauth = localauthservice.updatepassword(userId, oldpassword, newpassword);
            logger.info("********updatepassword out********:" + loaclauth);
            return loaclauth;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("*****updatepassword error******:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");
        }
        return jObject.toJSONString();
    }

    // 忘记密码
    @RequestMapping(value = "/api/user/public/forgetpassword", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})
    public String forgetpassword(HttpServletRequest request) {
        JSONObject jObject = new JSONObject();
        try {
            String body = readHttpBody(request);
            logger.info("********forgetpassword in********:" + body);
            JSONObject obj = JSONObject.parseObject(body);
            String phoneNum = obj.getString("phoneNum");
            String smscode = obj.getString("smscode");
            String password = obj.getString("password");
            logger.info("smscode user_id:{},oldpassword:{}, newpassword:{}", phoneNum, smscode, password);
            String loaclauth = localauthservice.forgetpassword(phoneNum, smscode, password);
            logger.info("********forgetpassword out********:" + loaclauth);
            return loaclauth;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("*****forgetpassword error******:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");
        }
        return jObject.toJSONString();
    }

    // 第三方 登录
    @RequestMapping(value = "/api/user/public/oauth", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})
    public String oauth(HttpServletRequest request) {
        JSONObject jObject = new JSONObject();
        try {
            request.setCharacterEncoding("UTF-8");
            String body = readHttpBody(request);
            logger.info("********oauth in********:" + body);
            String hostAddr = request.getRemoteAddr();
            JSONObject obj = JSONObject.parseObject(body);
            String oauthType = obj.getString("oauthType");
            String oauthId = obj.getString("oauthId");
            String nickName = obj.getString("nickName");
            String headPic = obj.getString("headPic");
            String deviceId = obj.getString("deviceId");
            logger.info("oauth oauth_type:{},oauth_id:{}, nick_name:{}, head_pic:{}, head_pic:{}, hostAddr:{}",
                    oauthType, oauthId, nickName, headPic, deviceId, hostAddr);
            String oauth = localauthservice.oauth(oauthType, oauthId, nickName, headPic, deviceId, hostAddr);
            logger.info("********oauth out********:" + oauth);
            return oauth;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("*****oauth error******:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");
        }
        return jObject.toJSONString();
    }

    // 生成一个不重复的id
    @RequestMapping(value = "/api/user/public/deviceId", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})
    public String device(HttpServletRequest request) {
        JSONObject info = new JSONObject();
        try {
            JSONObject jObject = new JSONObject();
            String deviceId = localauthservice.device();
            logger.info("********device in********:" + deviceId);
            if (deviceId != null) {
                jObject.put("result", "0");
                jObject.put("deviceId", deviceId);
                jObject.put("msg", "成功 ");
            } else {
                jObject.put("result", "1");
                jObject.put("msg", "deviceId为空");
            }
            logger.info("********device out********:" + deviceId);
            return jObject.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("*****device error******:", e);
            info.put("result", "1");
            info.put("msg", "异常");

        }
        return info.toJSONString();

    }

    // 退出
    @RequestMapping(value = "/api/user/public/logout", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})
    public String Logout(HttpServletRequest request) {
        JSONObject jObject = new JSONObject();
        try {
            String body = readHttpBody(request);
            logger.info("********Logout in********:" + body);
            JSONObject obj = JSONObject.parseObject(body);
            String ret = "";
            try {
                int userId = obj.getInteger("userId");
                int loginType = obj.getInteger("loginType") == null ? 0 : obj.getInteger("loginType");
                localauthservice.Logout(userId, loginType);
            } catch (Exception e) {
                logger.error("*****Logout error******:", e);
                e.printStackTrace();
            }
            return ret;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("*****Logout error******:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");
        }
        return jObject.toJSONString();
    }

    // 客户心跳包
    @RequestMapping(value = "/api/user/public/heartbeat", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})
    public String clientHeartbeat(HttpServletRequest request) {
        JSONObject jObject = new JSONObject();
        try {
            String body = readHttpBody(request);
            logger.info("********heartbeat in********:" + body);
            JSONObject obj = JSONObject.parseObject(body);

            int userId = obj.getInteger("userId");
            String deviceId = obj.getString("deviceId");
            String heartbeat = localauthservice.heartbeat(userId, deviceId);
            logger.info("********heartbeat out********:" + heartbeat);
            return heartbeat;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("*****clientHeartbeat error******:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");
        }
        return jObject.toJSONString();

    }

    // 统计在线人数int userId, int pageNum

    @RequestMapping(value = "/api/user/public/sonlinenum", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})

    public String sonlinenum(HttpServletRequest request) {
        JSONObject jObject = new JSONObject();
        try {
            String body = readHttpBody(request);
            logger.info("********sonlinenum in********:" + body);
            JSONObject obj = JSONObject.parseObject(body);
            int userId = obj.getInteger("userId") == null ? 0 : obj.getInteger("userId");
            int pageNum = obj.getInteger("pageNum") == null ? 1 : obj.getInteger("pageNum");
            int pageSize = obj.getInteger("pageSize") == null ? 10 : obj.getInteger("pageSize");
            String sonlinenum = localauthservice.sonlinenum(userId, pageNum, pageSize);
            logger.info("********sonlinenum out********:" + sonlinenum);
            return sonlinenum;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("*****sonlinenum error******:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");

        }

        return jObject.toJSONString();
    }

    /**
     * 分享推荐功能接口
     */

    @RequestMapping(value = "/api/user/getsharedata", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})

    public String getsharedata(HttpServletRequest request) {
        JSONObject jObject = new JSONObject();
        try {
            String body = readHttpBody(request);
            logger.info("********getsharedata in********:" + body);
            JSONObject obj = JSONObject.parseObject(body);
            int userId = obj.getInteger("userId");
            String ret = userservice.getsharedata(userId);
            logger.info("********getsharedata out********:" + ret);
            return ret;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("*****getsharedata error******:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");
        }
        return jObject.toJSONString();
    }

    /**
     * 获取用户信息
     */

    @RequestMapping(value = "/api2/getuserinfo", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})

    public String getUserInfo(HttpServletRequest request) {
        JSONObject jObject = new JSONObject();
        try {
            String body = readHttpBody(request);
            logger.info("********getuserinfo in********:" + body);
            JSONObject obj = JSONObject.parseObject(body);
            int userId = obj.getInteger("userId");
            String ret = userservice.getUserInfo(userId);
            logger.info("********getuserinfo out********:" + ret);
            return ret;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("*****getUserInfo error******:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");
        }
        return jObject.toJSONString();
    }

    /**
     * 获取用户登录情况
     */

    @RequestMapping(value = "/api2/getlastlogininfo", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})

    public String getLastLoginInfo(HttpServletRequest request) {
        JSONObject jObject = new JSONObject();
        try {
            String body = readHttpBody(request);
            logger.info("********getLastLoginInfo in********:" + body);
            JSONObject obj = JSONObject.parseObject(body);
            int userId = obj.getInteger("userId");
            int pageNum = obj.getInteger("pageNum") == null ? 1 : obj.getInteger("pageNum");
            int pageSize = obj.getInteger("pageSize") == null ? 10 : obj.getInteger("pageSize");
            String startTime = obj.getString("startTime") == null ? "19700101010100" : obj.getString("startTime");
            String endTime = obj.getString("endTime") == null ? DateUtil.getFormatDate("yyyyMMddHHmmss")
                    : obj.getString("endTime");
            String ret = userservice.getLastLoginInfo(userId, pageNum, pageSize, startTime, endTime);
            logger.info("********getLastLoginInfo out********:" + ret);
            return ret;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("*****getLastLoginInfo error******:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");
        }

        return jObject.toJSONString();
    }

    /**
     * 获取用户信息情况
     */

    @RequestMapping(value = "/api2/getuserinfos", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})

    public String getUserInfos(HttpServletRequest request) {
        JSONObject jObject = new JSONObject();
        try {
            String body = readHttpBody(request);
            logger.info("********getUserInfos in********:" + body);
            JSONObject obj = JSONObject.parseObject(body);
            int userId = obj.getInteger("userId") == null ? 0 : obj.getInteger("userId");
            int pageNum = obj.getInteger("pageNum") == null ? 1 : obj.getInteger("pageNum");
            int pageSize = obj.getInteger("pageSize") == null ? 10 : obj.getInteger("pageSize");
            String ret = userservice.selectUserInfoList(userId, pageNum, pageSize);
            logger.info("********getUserInfos out********:" + ret);
            return ret;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("*****getUserInfos error******:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");
        }

        return jObject.toJSONString();
    }

    /**
     * 更新用户状态
     */
    @RequestMapping(value = "/api2/updateuserstatus", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"})

    public String updateuserstatus(HttpServletRequest request) {
        JSONObject jObject = new JSONObject();
        try {
            String body = readHttpBody(request);
            logger.info("********getUserInfos in********:" + body);
            JSONObject obj = JSONObject.parseObject(body);
            int userId = obj.getInteger("userId");
            String state = obj.getString("state");
            String ret = userservice.updateUserState(userId, state);
            logger.info("********getUserInfos out********:" + ret);
            return ret;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("*****updateuserstatus error******:", e);
            jObject.put("result", "1");
            jObject.put("msg", "异常");
        }
        return jObject.toJSONString();
    }

    /*
     *
     *
     * JSONObject jObject = new JSONObject(); String body = readHttpBody(request);
     * logger.info("********createaccount********:" + body); JSONObject obj =
     * jObject.parseObject(body);
     *
     * String phone_num = obj.getString("phone_num"); String password =
     * obj.getString("password"); String smscode = obj.getString("smscode");
     * logger.info("smscode deviceId:{},phone_num:{}, vercode:{}", phone_num,
     * password, smscode);
     *
     * @SuppressWarnings("rawtypes")
     *
     * @ExceptionHandler(UserphoneNumException.class)
     *
     *  public ResultDto userName(UserphoneNumException e) {
     * e.printStackTrace(); return new ResultDto(); }
     *
     * @SuppressWarnings("rawtypes")
     *
     * @ExceptionHandler(UserphoneNumException.class) public ResultDto
     * password(UserphoneNumException e) { e.printStackTrace(); return new
     * ResultDto(); }
     */
}
